<template>
    <div class="app-container">
        <h1>App 根组件</h1>
        <hr/>
        <button @click="comName ='Left'">展示Left组件</button>
        <button @click="comName ='Right'">展示Right组件</button>
        <div class="box">
            <!-- 渲染 Left 组件和 Right 组件 -->
<!--            component标签是vue内置的，作用组件的占位符
                is属性的值，表示要渲染组件的名字
-->
            <keep-alive include="MyLeft">
                <component :is="comName"></component>
            </keep-alive>
        </div>
    </div>
</template>

<script>
import Left from "@/components/Left.vue";
import Right from "@/components/Right.vue";

export default {
    data() {
        return {
            // 要展示组件的名称
            comName: 'Left'
        }
    },
    components: {
        Left,
        Right
    }
}
</script>

<style lang="less">
.app-container {
  padding: 1px 20px 20px;
  background-color: #efefef;
}

.box {
  display: flex;
}
</style>
